package train48days;
import java.math.BigInteger;
import java.util.Scanner;
public class 进制转换 {
        public static void main(String[] args) {
            Scanner in=new Scanner(System.in);
            String m=in.next();
            int n=in.nextInt();
            BigInteger bi=new BigInteger(m,10);
            System.out.println(bi.toString(n).toUpperCase());
        }
    }
